package org.shana.shortlink.core.controller;

import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import lombok.RequiredArgsConstructor;
import org.shana.shortlink.core.service.ShortLinkService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class ShortLinkGoto {

    private final ShortLinkService shortLinkService;

    @GetMapping("/{short_url}")
    public void gotoLink(@PathVariable("short_url") String url,ServletRequest request,ServletResponse response){
        shortLinkService.restoreUrl(url, request, response);
    }
}
